/**
 * Simple regex experiment to create an automatic emoticons by Dharla Ferdana
 * Visit: http://www.dhf.web.id
 * And thanks for yahoo messenger
 * Update: 27 August 2013
 */

$(function() {

	// Append an emoticon bar before comment-form
	if (putEmoAbove) {
		$(putEmoAbove).before('<div class="heads-up" id="emoWrap"> :emo1: :emo2: :emo3: :emo4: :emo5: :emo6: :emo7: :emo8: :emo9: :emo10: :emo11: :emo12: :emo13: :emo14: :emo15: :emo16: :emo17: :emo18: :emo19: :emo20: :emo21: :emo22: :emo23: :emo24: :emo25: :emo26: :emo27: :emo28: :emo29: :emo30: :emo31: :emo32: :emo33: :emo34: :emo35: :emo36: :emo37: :emo38: :emo39: :emo40: :emo41: :emo42: :emo43: :emo44: :emo45: :emo46: :emo47: :emo48: :emo49: :emo50: :emo51: :emo52: :emo53: :emo54: :emo55: :emo56: :emo57: :emo58: :emo59: :emo60: :emo61: :emo62: :emo63: :emo64: :emo65: :emo66: :emo67: :emo68: :emo69: :emo70: :emo71: :emo72: :emo73: :emo74: :emo75: :emo76: :emo77: :emo78: :emo79: :emo80: :emo81: :emo82: :emo83: :emo84: :emo85: :emo86: :emo87: :emo88: :emo89: :emo90: :emo91: :emo92: :emo93: :emo94: :emo95: :emo96: :emo97: :emo98: :emo99: :emo100: :emo101: :emo102: :emo103: :emo104: :emo105: :emo106: :emo107: </div>');
	}
	function emot(emot, imgRep, emoKey) {
		$(emoRange).each(function() {
			$(this).html($(this).html()
			.replace(/<br ?\/?>(:|;|=|\^)/ig, "<br> $1")
			.replace(emot, " <img src='" + imgRep + "' class='emo delayLoad' alt='" + emoKey + "' />"));
		});
	}
	emot(/\s:emo1:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo1.gif", ":emo1:");
	emot(/\s:emo2:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo2.gif", ":emo2:");
	emot(/\s:emo3:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo3.gif", ":emo3:");
	emot(/\s:emo4:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo4.gif", ":emo4:");
	emot(/\s:emo5:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo5.gif", ":emo5:");
	emot(/\s:emo6:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo6.gif", ":emo6:");
	emot(/\s:emo7:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo7.gif", ":emo7:");
	emot(/\s:emo8:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo8.gif", ":emo8:");
	emot(/\s:emo9:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo9.gif", ":emo9:");
	emot(/\s:emo10:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo10.gif", ":emo10:");
	emot(/\s:emo11:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo11.gif", ":emo11:");
	emot(/\s:emo12:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo12.gif", ":emo12:");
	emot(/\s:emo13:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo13.gif", ":emo13:");
	emot(/\s:emo14:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo14.gif", ":emo14:");
	emot(/\s:emo15:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo15.gif", ":emo15:");
	emot(/\s:emo16:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo16.gif", ":emo16:");
	emot(/\s:emo17:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo17.gif", ":emo17:");
	emot(/\s:emo18:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo18.gif", ":emo18:");
	emot(/\s:emo19:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo19.gif", ":emo19:");
	emot(/\s:emo20:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo20.gif", ":emo20:");
	emot(/\s:emo21:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo21.gif", ":emo21:");
	emot(/\s:emo22:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo22.gif", ":emo22:");
	emot(/\s:emo23:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo23.gif", ":emo23:");
	emot(/\s:emo24:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo24.gif", ":emo24:");
	emot(/\s:emo25:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo25.gif", ":emo25:");
	emot(/\s:emo26:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo26.gif", ":emo26:");
	emot(/\s:emo27:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo27.gif", ":emo27:");
	emot(/\s:emo28:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo28.gif", ":emo28:");
	emot(/\s:emo29:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo29.gif", ":emo29:");
	emot(/\s:emo30:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo30.gif", ":emo30:");
	emot(/\s:emo31:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo31.gif", ":emo31:");
	emot(/\s:emo32:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo32.gif", ":emo32:");
	emot(/\s:emo33:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo33.gif", ":emo33:");
	emot(/\s:emo34:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo34.gif", ":emo34:");
	emot(/\s:emo35:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo35.gif", ":emo35:");
	emot(/\s:emo36:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo36.gif", ":emo36:");
	emot(/\s:emo37:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo37.gif", ":emo37:");
	emot(/\s:emo38:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo38.gif", ":emo38:");
	emot(/\s:emo39:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo39.gif", ":emo39:");
	emot(/\s:emo40:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo40.gif", ":emo40:");
	emot(/\s:emo41:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo41.gif", ":emo41:");
	emot(/\s:emo42:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo42.gif", ":emo42:");
	emot(/\s:emo43:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo43.gif", ":emo43:");
	emot(/\s:emo44:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo44.gif", ":emo44:");
	emot(/\s:emo45:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo45.gif", ":emo45:");
	emot(/\s:emo46:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo46.gif", ":emo46:");
	emot(/\s:emo47:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo47.gif", ":emo47:");
	emot(/\s:emo48:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo48.gif", ":emo48:");
	emot(/\s:emo49:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo49.gif", ":emo49:");
	emot(/\s:emo50:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo50.gif", ":emo50:");
	emot(/\s:emo51:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo51.gif", ":emo51:");
	emot(/\s:emo52:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo52.gif", ":emo52:");
	emot(/\s:emo53:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo53.gif", ":emo53:");
	emot(/\s:emo54:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo54.gif", ":emo54:");
	emot(/\s:emo55:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo55.gif", ":emo55:");
	emot(/\s:emo56:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo56.gif", ":emo56:");
	emot(/\s:emo57:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo57.gif", ":emo57:");
	emot(/\s:emo58:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo58.gif", ":emo58:");
	emot(/\s:emo59:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo59.gif", ":emo59:");
	emot(/\s:emo60:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo60.gif", ":emo60:");
	emot(/\s:emo61:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo61.gif", ":emo61:");
	emot(/\s:emo62:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo62.gif", ":emo62:");
	emot(/\s:emo63:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo63.gif", ":emo63:");
	emot(/\s:emo64:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo64.gif", ":emo64:");
	emot(/\s:emo65:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo65.gif", ":emo65:");
	emot(/\s:emo66:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo66.gif", ":emo66:");
	emot(/\s:emo67:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo67.gif", ":emo67:");
	emot(/\s:emo68:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo68.gif", ":emo68:");
	emot(/\s:emo69:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo69.gif", ":emo69:");
	emot(/\s:emo70:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo70.gif", ":emo70:");
	emot(/\s:emo71:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo71.gif", ":emo71:");
	emot(/\s:emo72:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo72.gif", ":emo72:");
	emot(/\s:emo73:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo73.gif", ":emo73:");
	emot(/\s:emo74:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo74.gif", ":emo74:");
	emot(/\s:emo75:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo75.gif", ":emo75:");
	emot(/\s:emo76:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo76.gif", ":emo76:");
	emot(/\s:emo77:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo77.gif", ":emo77:");
	emot(/\s:emo78:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo78.gif", ":emo78:");
	emot(/\s:emo79:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo79.gif", ":emo79:");
	emot(/\s:emo80:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo80.gif", ":emo80:");
	emot(/\s:emo81:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo81.gif", ":emo81:");
	emot(/\s:emo82:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo82.gif", ":emo82:");
	emot(/\s:emo83:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo83.gif", ":emo83:");
	emot(/\s:emo84:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo84.gif", ":emo84:");
	emot(/\s:emo85:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo85.gif", ":emo85:");
	emot(/\s:emo86:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo86.gif", ":emo86:");
	emot(/\s:emo87:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo87.gif", ":emo87:");
	emot(/\s:emo88:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo88.gif", ":emo88:");
	emot(/\s:emo89:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo89.gif", ":emo89:");
	emot(/\s:emo90:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo90.gif", ":emo90:");
	emot(/\s:emo91:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo91.gif", ":emo91:");
	emot(/\s:emo92:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo92.gif", ":emo92:");
	emot(/\s:emo93:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo93.gif", ":emo93:");
	emot(/\s:emo94:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo94.gif", ":emo94:");
	emot(/\s:emo95:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo95.gif", ":emo95:");
	emot(/\s:emo96:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo96.gif", ":emo96:");
	emot(/\s:emo97:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo97.gif", ":emo97:");
	emot(/\s:emo98:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo98.gif", ":emo98:");
	emot(/\s:emo99:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo99.gif", ":emo99:");
	emot(/\s:emo100:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo100.gif", ":emo100:");
	emot(/\s:emo101:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo101.gif", ":emo101:");
	emot(/\s:emo102:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo102.gif", ":emo102:");
	emot(/\s:emo103:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo103.gif", ":emo103:");
	emot(/\s:emo104:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo104.gif", ":emo104:");
	emot(/\s:emo105:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo105.gif", ":emo105:");
	emot(/\s:emo106:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo106.gif", ":emo106:");
	emot(/\s:emo107:/ig, "http://dhf-project.googlecode.com/svn/brain/emoticon/emo107.gif", ":emo107:");
    var one = 0; // Show alert one times!
    // Click anywhere to hide the emoticon
    $(document.body).on("click", function () {
        $('.emoKey').remove();
    });
    // Click to show the code!
    $('.emot').css('cursor', 'pointer').on("click", function (e) {
        $('.emoKey').remove();
        $(this).after('<input class="emoKey" type="text" size="6" value=" ' + this.alt + '" />');
        $('.emoKey').trigger("select");
        if (emoMessage && one === 0) {
            // Tampilkan kotak dialog di sini
            $('#alert-box').css('opacity', 1);
            $('#alert-box .message').html(emoMessage);
            one = 1;
        }
        e.stopPropagation();
    });
    $('#alert-box .close').on("click", function () {
        $('#alert-box').css('opacity', 0);
    });

});